﻿var RosChangeColor = function () {
    $(".Admin_Table tr:gt(0):even").css("background", "#F0F0E8");
    $(".Admin_Table tr:gt(0)").mouseover(function () {
        $(this).css("background", "#DAE9FB");
    });
    $(".Admin_Table tr:gt(0)").mouseout(function () {
        $(".Admin_Table tr:gt(0):even").css("background", "#F0F0E8");
        $(".Admin_Table tr:gt(0):odd").css("background", "");
    });
}

$(function() {
    RosChangeColor();
})

$(function () {
    var x = 10;
    var y = 10;
    // 左侧菜单效果
    $('.Menu').click(function () {
        var $NowMenu = $(this).next('.MenuNote');
        //$('.MenuNote').hide(400, function () { });
        if ($NowMenu.is(":visible")) {
            $NowMenu.hide(300, function () { });
        } else {
            $NowMenu.show(500, function () { });
        }
    });

    $('.CMenu').click(function () {
        var $NowMenu = $(this).next('.CMenuNote');
//        $('.CMenuNote').hide(400, function () { });
        if ($NowMenu.is(":visible")) {
            $NowMenu.hide(300, function () { });
        } else {
            $NowMenu.show(500, function () { });
        }
    });
});


function Delete(o, n) {
    if (confirm('确认删除本条记录吗?')) {
        var del = $(o);
        var Id = del.attr("id");
        var Id2 = del.attr("id2");
        var url = getRootPath() + "/TableHanders.aspx?act=d&type=1&tid=" + n + "&Id=" + Id + "&Id2=" + Id2 + "&ts=" + new Date().getTime();
        $.getJSON(url, function(data) {
            var sdata = data[0];
            var code = sdata.code;
            if (code == 0) {
                del.parent().parent().remove();
            }
            else {
                alert(sdata.msg);
            }
        });
    }
}

function SyncBaseT(o) {
    $(o).attr("disabled", "disabled");
    var arr = ["Category", "Category2", "Condition"];
    $("#syncInfo").html("开始同步数据,这可能需要5-10分钟的时间,具体情况视具体网速而定...");
   
    for (var i = 0; i < arr.length; i++) {
        $("#" + arr[i] + "Info").html("");
    }
    SyncTable(0, arr);
}
function SyncTable(index, arr) {
    var url = getRootPath() + '/ebayServices.ashx';
    $("#" + arr[index] + "Info").html("正在同步 - " + arr[index] + " - 的信息,请稍后...");
    $.get(url, { "act": "sync", "tname": arr[index], "ts": new Date().getTime() }, function(data, status) {
        if (status == "success") {
            var retData = EvalData(data);
            if (retData.retCode == 1001) {
                alert(retData.retMsg);
                return;
            }
            $("#" + arr[index] + "Info").html(retData.retCode == 0 ? "同步成功" : retData.retMsg);
            if (index < arr.length - 1) {
                index++;
                SyncTable(index, arr);
            }
            else {
                $("#syncInfo").html("本次同步结束!!!");
                $("#btnSync").removeAttr("disabled");
            }

        }
        else {
            $("#" + arr[index] + "Info").html(arr[index] + "同步失败");
            index++;
            SyncTable(index, arr);

        }
    });
}